<template>
  <!--材料类型管理-->
  <el-container>
    <el-header>
      <div class="left-panel">
        <!-- <el-button
          type="primary"
          icon="el-icon-plus"
          @click="add"
          v-auth-button="['add/industry']"
        ></el-button> -->
      </div>
      <div class="right-panel"></div>
    </el-header>
    <el-main class="nopadding">
      <scTable
        ref="table"
        :apiObj="apiObj"
        row-key="id"
        stripe
        :hidePagination="true"
      >
        <el-table-column
          label="类型名称"
          prop="name"
          min-width="100"
        ></el-table-column>
        <el-table-column label="描述" prop="description" min-width="200">
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="right" width="150">
          <template #default="scope">
            <el-button-group>
              <el-button
                text
                type="primary"
                size="small"
                @click="table_edit(scope.row, scope.$index)"
                v-auth-button="['update/industry']"
                >编辑</el-button
              >
            </el-button-group>
          </template>
        </el-table-column>
      </scTable>
    </el-main>
  </el-container>

  <save-dialog
    v-if="dialog.save"
    ref="saveDialog"
    @success="handleSaveSuccess"
    @closed="dialog.save = false"
  ></save-dialog>
</template>

<script>
import saveDialog from "./components/save"
export default {
  name: "industry",
  components: {
    saveDialog,
  },
  data () {
    return {
      dialog: {
        save: false,
      },
      apiObj: this.$API.material.getType,
    }
  },

  methods: {

    //编辑
    table_edit (row) {
      this.dialog.save = true
      this.$nextTick(() => {
        this.$refs.saveDialog.open("edit").setData(row)
      })
    },


    //本地更新数据
    handleSaveSuccess (data) {
      this.$refs.table.refresh()
    },
  },
};
</script>

<style></style>
